﻿using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teris
{
    public enum GAME_STATE
    {
        BEGIN,
        ONGOING,
        END
    }

    internal class Game
    {

        public const int w=50;
        public const int h=35;

        static ISceneUpdate[] scenes;
        static ISceneUpdate curScene;


        public Game()
        {
            Console.SetWindowSize(w, h);
            Console.SetBufferSize(w, h);
            Console.CursorVisible = false;

            scenes = new ISceneUpdate[3];
            scenes[0] = new BeginScenes();
            scenes[1] = new GameScene();
            scenes[2] = new EndScene();
            curScene = scenes[0];
        }

        public void Start()
        {
            while (true)
            {
                if (curScene != null)
                {
                    curScene.Update();
                }
            }
        }

        public static void ChangeState(GAME_STATE state)
        {
            Console.Clear();
            switch (state)
            {
                case GAME_STATE.BEGIN:
                    curScene = scenes[0];
                    break;
                case GAME_STATE.ONGOING:
                    curScene = scenes[1];
                    (curScene as GameScene)?.Start();
                    break;
                case GAME_STATE.END:
                    (curScene as GameScene)?.End();
                    curScene = scenes[2];
                    break;
            }
        }

    }
}
